package com.jintoufs.service.address.impl;

import com.jintoufs.dao.address.AddressMapper;
import com.jintoufs.domain.address.Address;
import com.jintoufs.service.address.AddressService;
import com.jintoufs.util.valid.ValidUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class AddressServiceImpl implements AddressService {
    @Resource
    private AddressMapper addressMapper;

    @Override
    public void save(Address address, String id) {
        if (!ValidUtil.isEmpty(id)){
            address.setId(id);
            addressMapper.insertSelective(address);
        }else {
            addressMapper.updateByPrimaryKeySelective(address);
        }
    }

    @Override
    public void delete(String id) {
        addressMapper.deleteByPrimaryKey(id);
    }

    @Override
    public List<Address> selectByParam(Map<String, Object> param) {
        return addressMapper.selectByParam(param);
    }
}
